﻿using System;
using CI;
using NUnit.Framework;
using System.IO;

namespace Globals.SystemTests
{
    [TestFixture]
    public class TraceLogger
    {

        private SimEnv _simEnv = SimEnv.Instance;
        /// <summary>
        /// Call the upload logs
        /// </summary>
        [Test]
        public void UploadLogsTrue()
        {
            _simEnv.TraceLogger.UploadLogs("test");              
        }

        /// <summary>
        /// get rid of long guid filenames
        /// </summary>
        [Test]
        public void PurgeGUIDLongFilenameLogFilesTrue()
        {
            // create a file and make sure its their
            Guid guidFilename = Guid.NewGuid();
            string fileName = guidFilename + "MesopotamiaTrace.log";
            string filePath = Path.Combine(CI.Utils.ResourceFolders.UsersResourceFolder(), fileName);
            StreamWriter sw = File.CreateText(filePath);
            sw.Write("test");
            sw.Close();
            Assert.IsTrue(File.Exists(filePath), "init file not created");

            // run method
            _simEnv.TraceLogger.PurgeGUIDLongFilenameLogFiles();

            // make sure file is not their now
            Assert.IsFalse(File.Exists(filePath), "file not deleted");
        }
    }
}
